import axios from 'axios'

// 高德地图驾车路径规划响应类型
interface GaoDeRouteResponse {
  status: string
  info: string
  infocode: string
  count: string
  route: {
    origin: string
    destination: string
    paths: Path[]
  }
}

interface Path {
  distance: string
  duration: string
  strategy: string
  tolls: string
  toll_distance: string
  steps: Step[]
  restriction: string
  traffic_lights: string
}

export interface Step {
  instruction: string
  orientation: string
  distance: string
  tolls: string
  toll_distance: string
  toll_road: never[] // 可根据实际数据结构进一步细化
  duration: string
  polyline: string
  action: string
  assistant_action: string
}

export async function getGaoDeRoute(start: string, end: string): Promise<GaoDeRouteResponse> {
  const result = await axios.get(
    `https://restapi.amap.com/v3/direction/driving?origin=${start}&destination=${end}&extensions=all&output=json&key=7f7a58932a276710392d574317aacdf4`,
  )
  return result.data
}
